<?php

namespace App\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use App\Models\Traits\CouponAddSelfHelper;
class Coupon extends Model
{
    //购物券发放
    use CouponAddSelfHelper;
    protected $fillable = [
        "end_date","title","descript","type","goods_id",
    ];

    public function user(){
        return $this->belongsTo(User::class);
    }

    public function couponsConfig(){
        return $this->belongsTo(CouponsConfig::class);
    }

    public function getIsPassedAttribute(){
        if ($this->end_date>=Carbon::now()->toDateString()){
            return false;
        }else{
            return true;
        }
    }
}
